package park.manage;

import java.util.Random;

public class CodeUtil {
    public static String getCode() {
        char []arr = new char [5];
        Random ran = new Random();
        char flag = (char)(ran.nextInt(26)+65);//大写
        int n;
        while(true){
            n=ran.nextInt(5);
            if(arr[n]=='\u0000'){
                arr[n] = flag;
                break;
            }
        }
        flag =  (char)(ran.nextInt(26)+97);//小写
        while(true){
            n=ran.nextInt(5);
            if(arr[n]=='\u0000'){
                arr[n] = flag;
                break;
            }
        }

        flag=  (char)(ran.nextInt(26)+97);//小写
        while(true){
            n=ran.nextInt(5);
            if(arr[n]=='\u0000'){
                arr[n] = flag;
                break;
            }
        }
        flag =  (char)(ran.nextInt(10)+48);//数字
        while(true){
            n=ran.nextInt(5);
            if(arr[n]=='\u0000'){
                arr[n] = flag;
                break;
            }
        }
        flag =  (char)(ran.nextInt(10)+48);//数字
        while(true){
            n=ran.nextInt(5);
            if(arr[n]=='\u0000'){
                arr[n] = flag;
                break;
            }
        }
        return new String(arr);
    }
}
